<?php
function tivi($height,$mode) {
$sql="SELECT * FROM `module` WHERE module_id=8";
$info=mysql_fetch_assoc(mysql_query($sql));
$link=''; 
switch ($info['module_data']) {
	//case 1:$link='123.30.108.77/live/THVL2/THVL2'; break;
	case 2:$link='video.lifetv.vn/mobi/vtv3.sdp'; break;
	//case 3:$link='123.30.108.77/live/THVL2/THVL2'; break;
	//case 4:$link='123.30.108.77/live/THVL2/THVL2';break;
	//case 5:$link='123.30.108.77/live/THVL2/THVL2';break;
}
	space(2);
	echo "<div class='player_swf'><div class='player' id='load_player'>
				<div id='mediaspace' style='width:465px;height:".$height."px;'>
					</div><div id='mediaspace2' style='width:0px; height:0px;'></div>";SWF();
	echo"<script type='text/javascript'>function playtivi(url)
					{var so=new SWFObject('media/player.swf','mpl','465','".$height."','9');
						so.addParam('allowfullscreen','true');
						so.addParam('allowscriptaccess','always');
						so.addVariable('stretching','fill');
						so.addVariable('abouttext','Cải lương Số');
						so.addVariable('aboutlink','/');so.addParam('wmode','opaque');
						if(url.indexOf('rtmp')>-1)	{
							so.addVariable('streamer',url.substring(0,url.lastIndexOf('/')+1));
							so.addVariable('file',url.substring(url.lastIndexOf('/')+1));
						}
						else so.addVariable('file',url);so.addVariable('stretching','fill');
						so.addVariable('controlbar','bottom');
						so.addVariable('autostart','".$mode."'); 
						so.addVariable('volume','100');
						so.write('mediaspace');document.getElementById('mediaspace2').innerHTML='';}
						playtivi('rtmp://".$link."');</script></div></div>";
}
//-----------------------------------------------------------
function video($link,$height,$mode){space(2);echo "<div class='player_swf'><div class='player' id='load_player'>";SWF();echo"
<embed name='mediaplayer' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' width='465' height='".$height."' bgcolor='#FFFFFF' src='media/player.swf' allowfullscreen='true'allowscriptaccess='always' flashvars='file=".$link."&autostart=".$mode."&repeat=always&plugins=hd-1&logo.file=media/icon/logovideo.png&logo.position=top-left&logo.hide=false&logo.out=0.7&abouttext=Cải lương Số&aboutlink=?page=audio&song=3987&stretching=fill&logo.over=1&modestbranding=0'></embed>
</div></div>";}
//----------------------------------------------------------
function analysis(){
	  
}
//-----------------------------------------------------------
function slide(){
echo '<div class="slider-wrapper theme-default">
            <div class="ribbon"></div>
            <div id="slider" class="nivoSlider">
                <img src="http://beta.cailuongso.com/nivo-slider/demo/images/hihi.png" data-transition="slideInLeft"  alt="" title="#cap1" />
                <img src="http://beta.cailuongso.com/nivo-slider/demo/images/hihi.png" data-transition="slideInLeft" alt="" title="#cap2" />
            </div>
            <div id="cap1" class="nivo-html-caption">
                OFFLINE lần thứ 31
            </div>
			<div id="cap2" class="nivo-html-caption">
                OFFLINE lần thứ 32
            </div>
        </div>
    <script type="text/javascript" src="http://beta.cailuongso.com/nivo-slider/jquery.nivo.slider.js"></script>
    <script type="text/javascript">
    $(window).load(function() {
        $("#slider").nivoSlider();
    });
    </script>
';
}
//-----------------------------------------------------------
function setalbum($n){
$sql="SELECT * FROM `album` WHERE album_set=1 LIMIT 0,".$n;
$excute=mysql_query($sql);
$dem=0;
echo'<div class="items2">';
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){ 
	$dem++;
	echo '<div class="albumhot">';
	if ($dem%3!=0) echo '<div class="album12">'; else echo '<div class="album3">'; 
	echo '
    <a title="'.$row['album_name'].'" href="http://beta.cailuongso.com/album/'.isolink($row['album_name']).'/'.$row['album_hash'].'.html">
    <img src="';
	echo (substr($row['album_img'],0,4)=='data')?'http://beta.cailuongso.com/':'';
	echo $row['album_img'].'" /></a>
	<div class="box">
	<a class="title" title="'.$row['album_name'].'" href="http://beta.cailuongso.com/album/'.isolink($row['album_name']).'/'.$row['album_hash'].'.html">'.readmore($row['album_name'],4).'</a><br/>
	<a class="singeralbum" title="'.decode($row['album_artist']).'" href="/">'.readmore(decode($row['album_artist']),5).'</a>
	</div>
	</div>
	</div>';
	}
echo '
<div class="clr"></div> 
    </div>';
}

function albumhot($n){
$sql="SELECT * FROM `album` ORDER BY  `album_id` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
$dem=0;
echo'<div class="items2">';
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){ 
	$dem++;
	echo '<div class="albumhot">';
	if ($dem%3!=0) echo '<div class="album12">'; else echo '<div class="album3">'; 
	echo '
    <a title="'.$row['album_name'].'" href="http://beta.cailuongso.com/album/'.isolink($row['album_name']).'/'.$row['album_hash'].'.html">
    <img src="http://beta.cailuongso.com/'.$row['album_img'].'" /></a>
	<div class="box">
	<a class="title" title="'.$row['album_name'].'" href="http://beta.cailuongso.com/album/'.isolink($row['album_name']).'/'.$row['album_hash'].'.html">'.readmore($row['album_name'],4).'</a><br/>
	<a class="singeralbum" title="'.decode($row['album_artist']).'" href="/">'.readmore(decode($row['album_artist']),5).'</a>
	</div>
	</div>
	</div>';
	}
echo '
<div class="clr"></div>
    </div>';
}  
//---------------------------------------------------------------
function videohot($n){
$sql="SELECT * FROM `media` WHERE (media_link LIKE '%youtu%') ORDER BY  `media_id` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
$dem=0;
echo'<div class="item">';
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){ 
	$dem++;
	echo '<div class="videohot">';
	if ($dem%3!=0) echo '<div class="video12">'; else echo '<div class="video3">'; 
	echo '
    <a title="'.$row['media_name'].'" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">
    <img src="http://beta.cailuongso.com/'.$row['media_img'].'" /></a>';
	space(1);
	echo'<a class="title" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.readmore($row['media_name'],3).'</a><br />
    <a class="singer" title="'.decode($row['media_artist']).'">'.readmore(decode($row['media_artist']),5).'</a>
	</div>
	</div>';
	}
echo '<div class="clr"></div>
    </div>';
}  
//-----------------------------------------------------------------
function audiohot($n){
echo '<div class="boder_h2">';
$sql="SELECT * FROM `media` WHERE media_link LIKE '%mp3%' ORDER BY  `media_id` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	echo'<div class="list_song"><div class="c002">';
	echo '<a class="title" title="Nghe bài hát '.$row['media_name'].'" href="http://beta.cailuongso.com/audio/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.$row['media_name'].'</a>';
echo'<br/><a class="singer" title="Tìm kiếm bài hát của ca sĩ '.$row['media_artist'].'" href="/?key='.$row['media_artist'].'">'.readmore_no(decode($row['media_artist']),5).'</a> | Thể loại:&nbsp<a class="cat" href="/?key='.$row['media_cat'].'">'.decode_cat($row['media_cat']).'</a>';
echo '<a class="singer" href="/?key='.$row['media_artist'].'"></a>| Lượt nghe: '.$row['media_view'].'</div>';
echo '<div class="c003">
        	<a href="/download.php?id='.md5($row['media_id']."memhuynh").'" title="Tải bài hát '.$row['media_name']. 'về máy"><img src="http://beta.cailuongso.com/media/icon/down.png" border="0" /></a>&nbsp;&nbsp;&nbsp;<a title="Thêm bài hát '.$row['media_name'].' vào giỏ nhạc" style="cursor:pointer;"><img src="http://beta.cailuongso.com/media/icon/add.png" /></a>';			
    echo '</div></div>';
	}
echo '</div>';
}
//--------------------------------------------------------
function adv($file,$width,$height){echo'<embed type="application/x-shockwave-flash" width="'.$width.'px" height="'.$height.'px" src="http://beta.cailuongso.com/media/adv/'.$file.'.swf" wmode="transparent" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high"></embed>';
}
function adv2($file,$width,$height){echo'<embed type="application/x-shockwave-flash" width="'.$width.'px" height="'.$height.'px" src="http://beta.cailuongso.com/media/adv/'.$file.'.swf" wmode="transparent" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high"></embed>';
}

//---------------------------------------------------------
function tabcls1()
{
	space(7);
echo '
<div id="containerx"></div>
		<div class="spacemedia"></div>
<script type="text/javascript">
	   jwplayer("containerx").setup({
        file: "http://www.youtube.com/watch?v=zIoVkwAUlco",
        flashplayer: "http://beta.cailuongso.com/media/player.swf",
        height: 240,
        width: 310,
		autostart:false,	
		abouttext:"Cải lương Số",
		aboutlink:"http://beta.cailuongso.com",
		dock:true,
		controlbar:"bottom",
    });
</script> ';		 
}

function tabcls2()
{
echo '<div id="newaudio">';
echo '<table width="273" height="273" border="1"><tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>';
echo '</div>';     
}

function tabcls3()
{
echo '<div id="newaudio">';
echo '
<div class="tab_cls3"><a href="http://diendan.cailuongso.com/forumdisplay.php?f=71">Giới thiệu thành viên</a></div>
<div class="tab_cls3"><a href="http://diendan.cailuongso.com/forumdisplay.php?f=71">Giới thiệu thành viên</a></div>
<div class="tab_cls3"><a href="http://diendan.cailuongso.com/forumdisplay.php?f=71">Giới thiệu thành viên</a></div>
<div class="tab_cls3"><a href="http://diendan.cailuongso.com/forumdisplay.php?f=71">Giới thiệu thành viên</a></div>
</div>';  
}
//---------------------------------------------------------

function albumscat($id){
$cmd="SELECT * FROM `album` WHERE album_id=".$id;
$info=mysql_fetch_assoc(mysql_query($cmd));
$cmd="SELECT * FROM `album` WHERE album_cat=".$info['album_cat'];
$excute=mysql_query($cmd);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){
		$dem++;
		echo '<div class="rankvideo">';
		echo '<table border="0" width="100%">
		<tr>
			<td><img class="imgalbum" src="';
		if (substr($row['album_img'],0,4)=='http') echo $row['album_img']; else echo 'http://beta.cailuongso.com/'.$row['album_img'];
		echo'"/></td>
			<td style="vertical-align:top" width="205px">
			<a class="title" href="http://beta.cailuongso.com/album/'.isolink($row['album_name']).'/'.$row['album_hash'].'.html">'.$row['album_name'].'</a><br/>';
		echo '<a class="artist"> '.readmore(decode($row['album_artist']),5).'<br/>
			 Lượt xem : '.$row['album_view'].'</a>
		
			</td>
		</tr>
		</table>
		';
		echo '</div>';
	if ($dem==$n) break;
		
	}   
}
//----------------------------------------------------------
function videoscat($id)
{
$cmd="SELECT * FROM `media` WHERE media_id=".$id;
$info=mysql_fetch_assoc(mysql_query($cmd));
$sql="SELECT * FROM `media` WHERE (media_link LIKE '%youtu%') AND (media_cat='".$info['media_cat']."') ORDER BY  `media_id` DESC LIMIT 0,5";
$excute=mysql_query($sql);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){
		$dem++;
		echo '<div class="rankvideo">';
		echo '<table border="0" width="100%">
		<tr>
			<td><img class="imgvideo" src="';	
		if ($row['media_img']=='') echo 'http://lh5.googleusercontent.com/-SfX6QgaXADw/T9KKUPJmQFI/AAAAAAAAAKs/qXHOP7mgVmY/s190/cailuongso.com-Capture.PNG'; else echo 'http://beta.cailuongso.com/'.$row['media_img'];
		echo'"/></td>
			<td style="vertical-align:top" width="205px">
			<a class="title" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.readmore($row['media_name'],6).'</a><br/>';
		echo '<a class="artist">'.readmore(decode($row['media_artist']),5).'<br/>
			 Lượt xem : '.$row['media_view'].'</a>
		
			</td>
		</tr>
		</table>
		';
		echo '</div>';
	if ($dem==$n) break;
		
	}   
}
//----------------------------------------------------------
function audioscat($id)
{
$cmd="SELECT * FROM `media` WHERE media_id=".$id;
$info=mysql_fetch_assoc(mysql_query($cmd));
$sql="SELECT * FROM `media` WHERE (media_link LIKE '%mp3%') AND (media_cat='".$info['media_cat']."') ORDER BY  `media_id` DESC LIMIT 0,5";
$excute=mysql_query($sql);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){
		$dem++;
		echo '<div class="rankvideo">';
		echo '<table border="0" width="100%">
		<tr>
		    <td width="20px">
			<div class="headaudio"></div>
		    </td> 
			<td style="vertical-align:top" width="205px"> 
			<a class="title" href="http://beta.cailuongso.com/audio/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.readmore($row['media_name'],5).'</a><br/>';
		echo '<a class="artist"> '.readmore(decode($row['media_artist']),5).'<br/>
			 Lượt xem : '.$row['media_view'].'</a>
		
			</td>
		</tr>
		</table>
		';
		echo '</div>';
	if ($dem==$n) break;
		
	}   
}
//----------------------------------------------------------
function newalbum($n)
{
$cmd="SELECT * FROM `album` ORDER BY album_id DESC LIMIT 0,5";
$excute=mysql_query($cmd);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){
		$dem++;
		echo '<div class="rankvideo">';
		echo '<table border="0" width="100%">
		<tr>
			<td><img class="imgalbum" src="';
		if (substr($row['album_img'],0,4)=='http') echo $row['album_img']; else echo 'http://beta.cailuongso.com/'.$row['album_img'];
		echo'"/></td>
			<td style="vertical-align:top" width="205px">
			<a class="title" href="http://beta.cailuongso.com/video/'.isolink($row['album_name']).'/'.$row['album_hash'].'.html">'.$row['album_name'].'</a><br/>';
		echo '<a class="artist"> '.readmore(decode($row['album_artist']),5).'<br/>
			 Lượt xem : '.$row['album_view'].'</a>
		
			</td>
		</tr>
		</table>
		';
		echo '</div>';
	if ($dem==$n) break;
		
	}   
}
//-----------------------------------------------------------------
function newvideo($n)
{
$sql="SELECT * FROM `media` WHERE (media_link LIKE '%youtu%') AND (media_album=0) ORDER BY  `media_id` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){
		$dem++;
		echo '<div class="rankvideo">';
		echo '<table border="0" width="100%">
		<tr>
			
			<td><img class="imgvideo" src="';	
		if ($row['media_img']=='') echo 'http://lh5.googleusercontent.com/-SfX6QgaXADw/T9KKUPJmQFI/AAAAAAAAAKs/qXHOP7mgVmY/s190/cailuongso.com-Capture.PNG'; else echo 'http://beta.cailuongso.com/'.$row['media_img'];
		echo'"/></td>
			<td style="vertical-align:top" width="205px">
			<a class="title" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.readmore($row['media_name'],5).'</a><br/>';
		echo '<a class="artist">'.readmore(decode($row['media_artist']),5).'<br/>
			 Lượt xem : '.$row['media_view'].'</a>
		
			</td>
		</tr>
		</table>
		';
		echo '</div>';
	if ($dem==$n) break;
		
	}  
}
//-----------------------------------------------------------
function newaudio($n)
{
$sql="SELECT * FROM `media` WHERE (media_link LIKE '%mp3%') ORDER BY  `media_id` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){
		$dem++;
		echo '<div class="rankvideo">';
		echo '<table border="0" width="100%">
		<tr>
		 <td width="20px">
			<div class="headaudio"></div>
		    </td> 
			<td style="vertical-align:top" width="205px">
			<a class="title" href="http://beta.cailuongso.com/audio/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.$row['media_name'].'</a><br/>';
		echo '<a class="artist"> '.readmore(decode($row['media_artist']),5).'<br/>
			 Lượt xem : '.$row['media_view'].'</a>
		
			</td>
		</tr>
		</table>
		';
		echo '</div>';
	if ($dem==$n) break;
		
	} 
}
// FORUM -----------------------------------------------
function fourumtopupload($n)
{
sql2();
$cmd='SELECT * FROM  `user` ORDER BY user_upload DESC  LIMIT 0,'.$n;
	$excute=mysql_query($cmd);
	echo '<table border="0" class="newcomment" width="250px">';
	while ($info=mysql_fetch_array($excute,MYSQL_ASSOC)){
	
echo '<tr>';
echo '<td width="70px"><img src="http://diendan.cailuongso.com/image.php?u='.$info['userid'].'" ></td>'; 
echo '<td style="vertical-align:top"><a class="member" href="">'.$info['username'].'</a></td>';
echo '</tr>';}
echo '</table>';
sql();	
echo '</div></div>';
}

function forumvideo($n)
{
$sql="SELECT * FROM `media` WHERE (media_link LIKE '%youtu%') ORDER BY  `media_id` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){
		$dem++;
		echo '<div class="rankvideo">';
		echo '<table border="0" width="100%">
		<tr>
			<td><img class="imgvideo" src="http://beta.cailuongso.com/'.$row['media_img'].'"/></td>
			<td style="vertical-align:top" width="150px">
			<a class="title" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.readmore($row['media_name'],4).'</a><br/>';
		echo '<a class="artist"> '.readmore(decode($row['media_artist']),3).'<br/>
			 Lượt xem : '.$row['media_view'].'</a>
		
			</td>
		</tr>
		</table>
		';
		echo '</div>';
	if ($dem==$n) break;
		
	}    
}

function forumaudio($n){
$sql="SELECT * FROM `media` WHERE media_link LIKE '%mp3%' ORDER BY  `media_id` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
$dem=0;
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){ 
	$dem++;
		echo '<div class="rankaudio">';
		if (($dem==1)||($dem==2)||($dem==3)) echo '<div id="rankacolorx'.$dem.'"></div>'; else
		echo '<div id="rankacolorx4"></div>';
		echo '<a class="title" href="http://beta.cailuongso.com/audio/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.readmore($row['media_name'],6).'</a><br/>';
		echo '<a class="artist"> '.readmore(decode($row['media_artist']),6).'<span>';
		echo '</div>';
	if ($dem==$n) break;
	}  
}
//---------------------------------------------------------
function rankalbum($n)
{
$sql="SELECT * FROM `album` ORDER BY  `album_view` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
echo '<div id="newaudio">';
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){ 
	echo '<div class="rankalbum">';
	space(2);
	echo'<table width="100%" border="0"><tr>
		<td width="110px"><img src="'.$row['album_link'].'"></td>
		<td style="vertical-align:top">
		<a class="title" href="/">'.$row['album_name'].'</a>
		<br/>
		<a>'.$row['album_artist'].'</a>
		<br/>
		<a>Lượt nghe :'.$row['album_view'].'</a>
		</td>
		<tr>
		</table></div>';
	}
echo '</div>';     
}

function rankvideo($n)
{
$sql="SELECT * FROM `media` WHERE (media_link LIKE '%youtu%') AND (media_album=0) ORDER BY  `media_view` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){
		$dem++;
		echo '<div class="rankvideo">';
		echo '<table border="0" width="100%">
		<tr>
			<td><img class="imgvideo" title="'.$row['media_name'].'" src="http://beta.cailuongso.com/'.$row['media_img'].'"/></td>
			<td style="vertical-align:top" width="205px">
			<a class="title" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.$row['media_name'].'</a><br/>';
		echo '<a class="artist"> '.readmore(decode($row['media_artist']),5).'<br/>
			 Lượt xem : '.$row['media_view'].'</a>
		
			</td>
		</tr>
		</table>
		';
		echo '</div>';
	if ($dem==$n) break;
		
	}    
}

function rankaudio($n){
$sql="SELECT * FROM `media` WHERE media_link LIKE '%mp3%' ORDER BY  `media_view` DESC LIMIT 0,".$n;
$excute=mysql_query($sql);
$dem=0;
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){ 
	$dem++;
		echo '<div class="rankaudio">';
		if (($dem==1)||($dem==2)||($dem==3)) echo '<div id="rankacolorx'.$dem.'"></div>'; else
		echo '<div id="rankacolorx4"></div>';
		echo '<a class="title" href="http://beta.cailuongso.com/audio/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.$row['media_name'].'</a><br/>';
		echo '<a class="artist"> '.readmore(decode($row['media_artist']),6).'<span>';
		echo '</div>';
	if ($dem==$n) break;
	}  
}
//---------------------------------------------------------
function topupload($n){	
sql2();	
$cmd='SELECT * FROM  `user` ORDER BY `user_upload` DESC LIMIT 0 ,'.$n;
	$excute=mysql_query($cmd);
	while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{	
	   echo'<li';
	   if ($_GET['upload']==$info['user_hash']) echo ' class="mark" ';
	   echo '><a href="http://beta.cailuongso.com/Đăng-nhạc/'.isolink($info['username']).'/'.$info['user_hash'].'.html">
	  <span>'.$info['username'].' ('.$info['user_upload'].')</span></a></li>';
	}
sql();	 
}
//---------------------------------------------------------
function member($n){
sql2();	
$cmd='SELECT `username`,`user_upload`,`userid` FROM  `user` ORDER BY  `user`.`user_upload` DESC LIMIT 0 , '.$n;
	$excute=mysql_query($cmd);
	while ($info=mysql_fetch_array($excute,MYSQL_ASSOC)){
	echo'<li><a href="http://diendan.cailuongso.com/member.php?u='.$info['userid'].'">
	<span>'.$info['username'].' ( '.$info['user_upload'].')</span></a></li>';}
sql();	
}
//---------------------------------------------------------
function newcomment($n){
	echo'<div class="module module_menu"><h3><span>CẢM NHẬN</span></h3>';
	$cmd='SELECT * FROM  `comment` ORDER BY comment_time DESC  LIMIT 0,'.$n;
	$excute=mysql_query($cmd);
	echo '<table border="0" class="newcomment" width="100%">';
	while ($info=mysql_fetch_array($excute,MYSQL_ASSOC)){
	
echo '<tr>';
echo '<td width="70px"><img src="http://diendan.cailuongso.com/image.php?u='.$info['comment_poster'].'" ></td>'; 
echo '<td style="vertical-align:top"><a class="member" href="'.$info['comment_link'].'">'.finduser($info['comment_poster']).' </a><a class="commentext"  title="'.$info['comment_text'].'"> '.readmore($info['comment_text'],10).'</a><br/>Vào lúc: '.changetime($info['comment_time']).' trước</a></td>';
echo '</tr>';}
echo '</table>';
	sql();	
echo '</div>';
}
//---------------------------------------------------------
function analys(){echo'<div class="module module_menu"><h3><span>THỐNG KÊ</span></h3>
	  <br/>	
      <b>ALBUM:</b><br/>
	  <b>VIDEO: </b><br/>
	  <b>AUDIO: </b><br/>
	  <b>Đang online: </b><br/>
	  <b>Thành viên: </b><br/>
</div>';
}
//----------------------------------------------------------
function search_artist($key,$n){
echo '<div class="boder_h2">';
$key=sqlprotect($key);	
$sql="SELECT * FROM  `select` WHERE `select_tag` LIKE '%$key%' LIMIT 0,".$n;
$excute=mysql_query($sql);
if (mysql_num_rows($excute)>0)
{
menu('TÌM THEO NGHỆ SĨ VÀ SOẠN GIẢ');
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	echo'<div class="list_song"><div class="c002">';
	echo '<a class="title" title="Nghệ sĩ '.$row['select_art'].'" href="http://beta.cailuongso.com/artist/'.isolink($row['select_art']).'/'.$row['select_hash'].'.html">'.$row['select_art'].'</a>
	</div>';
echo '<div class="c003"><a></a>';			
    echo '</div></div>';
	}
}
echo '</div>';
}
//----------------------------------------------------------
function search_album($key,$n){
echo '<div class="boder_h2">';
$key=sqlprotect($key);	
$sql="SELECT * FROM  `album` WHERE `album_tag` LIKE '%$key%' LIMIT 0,".$n;
$excute=mysql_query($sql);
if (mysql_num_rows($excute)>0)
{
menu('TÌM THEO ALBUM');
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	echo'<div class="list_song"><div class="c002">';
	echo '<a class="title" title="Nghe bài hát '.$row['album_name'].'" href="http://beta.cailuongso.com/album/'.isolink($row['album_name']).'/'.$row['album_hash'].'.html">'.$row['album_name'].'</a>
	</div>';
echo '<div class="c003"><a></a>';			
    echo '</div></div>';
	}
}
echo '</div>';
}
//----------------------------------------------------------
function search_video($key,$n){
$key=sqlprotect($key);	
echo '<div class="boder_h2">';
$sql="SELECT * FROM  `media` WHERE (media_link LIKE '%youtu%') AND (`media_tag` LIKE '%$key%') LIMIT 0,".$n;
$excute=mysql_query($sql);
if (mysql_num_rows($excute)>0)
{ 
menu('TÌM THEO VIDEO');
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	echo'<div class="list_song"><div class="c002">';
	echo '<a class="title" title="Nghe bài hát '.$row['media_name'].'" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.$row['media_name'].'</a>';
	
echo'<br/> <a class="singer" title="Tìm kiếm bài hát của ca sĩ '.$row['media_singer'].'">'.decode($row['media_artist']).'</a> | <a class="cat" href="/?key='.$row['media_cat'].'">'.$row['media_cat'].'</a>';
echo '<a class="singer" href="/?key='.$row['media_singer'].'"></a>| Lượt nghe: '.$row['media_view'].'</div>';
echo '<div class="c003">
        	<a href="/?download='.$row['media_id'].'" target="_blank" title="Tải bài hát '.$row['media_name']. 'về máy"><img src="media/icon/down.png" border="0" /></a>&nbsp;&nbsp;&nbsp;<a title="Thêm bài hát '.$row['media_name'].' vào giỏ nhạc" style="cursor:pointer;"><img src="media/icon/add.png" /></a>';			
    echo '</div></div>';
	}
}
echo '</div>';
}
//---------------------------------------------------------
function search_audio($key,$n){
echo '<div class="boder_h2">';
$sql="SELECT * FROM  `media` WHERE (media_link LIKE '%mp3%') AND (`media_tag` LIKE '%$key%') LIMIT 0,".$n;
$excute=mysql_query($sql);
if (mysql_num_rows($excute)>0)
{
menu('TÌM THEO AUDIO');
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	echo'<div class="list_song"><div class="c002">';
	echo '<a class="title" title="Nghe bài hát '.$row['media_name'].'" href="http://beta.cailuongso.com/audio/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.$row['media_name'].'</a>';
	
echo'<br/> <a class="singer" title="Tìm kiếm bài hát của ca sĩ '.$row['media_singer'].'" href="/?key='.$row['media_singer'].'">'.decode($row['media_artist']).'</a> | <a class="cat" href="/?key='.$row['media_cat'].'">'.$row['media_cat'].'</a>';
echo '<a class="singer" href="/?key='.$row['media_singer'].'"></a>| Lượt nghe: '.$row['media_view'].'</div>';
echo '<div class="c003">
        	<a href="download.php?id='.md5($row['media_id']."memhuynh").'" title="Tải bài hát '.$row['media_name']. 'về máy"><img src="media/icon/down.png" border="0" /></a>&nbsp;&nbsp;&nbsp;<a title="Thêm bài hát '.$row['media_name'].' vào giỏ nhạc" style="cursor:pointer;"><img src="media/icon/add.png" /></a>';			
    echo '</div></div>';
	}
}
echo '</div>';
}

//----------------------------------------------------------
function showcatvideo($cat)
{
space(2);
$sql="SELECT * FROM `media` WHERE (media_cat=".$cat.") AND (media_link LIKE '%youtu%') LIMIT 0,20";
$excute=mysql_query($sql);
$dem=0;
echo'<div class="item">';
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){ 
	$dem++;
	echo '<div class="videohot">';
	if ($dem%3!=0) echo '<div class="video12">'; else echo '<div class="video3">'; 
	echo '
    <a title="'.$row['media_name'].'" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">
    <img src="http://beta.cailuongso.com/'.$row['media_img'].'" /></a>';
	space(1);
	echo'<a class="title" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.readmore($row['media_name'],4).'</a><br />
    <a class="singer" title="'.decode($row['media_artist']).'">'.readmore(decode($row['media_artist']),5).'</a>
	</div>
	</div>';
	}
echo '<div class="clr"></div>
    </div>';
}
//-----------------------------------------------------------
function showcataudio($cat)
{
	$sql="SELECT * FROM `media` WHERE (media_cat=".$cat.") AND (media_link LIKE '%mp3%') LIMIT 0,20";
	$cmd=mysql_query($sql);
	while ($row=mysql_fetch_array($cmd,MYSQL_ASSOC))
	{
	echo'<div class="list_song"><div class="c002">';
	echo '<a class="title" title="Nghe bài hát '.$row['media_name'].'" href="http://beta.cailuongso.com/audio/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.$row['media_name'].'</a>';
echo'<br/><a class="singer" title="Tìm kiếm bài hát của ca sĩ '.$row['media_artist'].'" href="/?key='.$row['media_artist'].'">'.readmore_no(decode($row['media_artist']),5).'</a> | Thể loại:&nbsp<a class="cat" href="/?key='.$row['media_cat'].'">'.decode_cat($row['media_cat']).'</a>';
echo '<a class="singer" href="/?key='.$row['media_artist'].'"></a>| Lượt nghe: '.$row['media_view'].'</div>';
echo '<div class="c003">
        	<a href="/download.php?id='.md5($row['media_id']."memhuynh").'" title="Tải bài hát '.$row['media_name']. 'về máy"><img src="http://beta.cailuongso.com/media/icon/down.png" border="0" /></a>&nbsp;&nbsp;&nbsp;<a title="Thêm bài hát '.$row['media_name'].' vào giỏ nhạc" style="cursor:pointer;"><img src="http://beta.cailuongso.com/media/icon/add.png" /></a>';			
    echo '</div></div>';
	}
}
//----------------------------------------------------------
function showcataudio2($user){
sql();
	$sql="SELECT * FROM `media` WHERE (media_poster='".$user."') AND (media_link LIKE '%mp3%') LIMIT 0,20";
	$excute=mysql_query($sql);
	if (mysql_num_rows($excute)==0) echo '<br/>Chưa có audio nào !<br/>';
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	echo'<div class="list_song"><div class="c002">';
	echo '<a class="title" title="Nghe bài hát '.$row['media_name'].'" href="http://beta.cailuongso.com/audio/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.$row['media_name'].'</a>';
echo'<br/><a class="singer" title="Tìm kiếm bài hát của ca sĩ '.$row['media_artist'].'" href="/?key='.$row['media_artist'].'">'.readmore_no(decode($row['media_artist']),5).'</a> | Thể loại:&nbsp<a class="cat" href="/?key='.$row['media_cat'].'">'.decode_cat($row['media_cat']).'</a>';
echo '<a class="singer" href="/?key='.$row['media_artist'].'"></a>| Lượt nghe: '.$row['media_view'].'</div>';
echo '<div class="c003">
        	<a href="/download.php?id='.md5($row['media_id']."memhuynh").'" title="Tải bài hát '.$row['media_name']. 'về máy"><img src="http://beta.cailuongso.com/media/icon/down.png" border="0" /></a>&nbsp;&nbsp;&nbsp;<a title="Thêm bài hát '.$row['media_name'].' vào giỏ nhạc" style="cursor:pointer;"><img src="http://beta.cailuongso.com/media/icon/add.png" /></a>';			
    echo '</div></div>';
	}
}
//----------------------------------------------------------
function showcatvideo2($user){
sql();
	$sql="SELECT * FROM `media` WHERE (media_poster='".$user."') AND (media_link LIKE '%youtu%') LIMIT 0,20";
	$excute=mysql_query($sql);
	echo'<div class="item">';
	if (mysql_num_rows($excute)==0) echo '<br/>Chưa có video nào !<br/>';
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC)){ 
	$dem++;
	echo '<div class="videohot">';
	if ($dem%3!=0) echo '<div class="video12">'; else echo '<div class="video3">'; 
	echo '
    <a title="'.$row['media_name'].'" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">
    <img src="http://beta.cailuongso.com/'.$row['media_img'].'" /></a>';
	space(1);
	echo'<a class="title" href="http://beta.cailuongso.com/video/'.isolink($row['media_name']).'/'.$row['media_hash'].'.html">'.readmore($row['media_name'],4).'</a><br />
    <a class="singer" title="'.decode($row['media_artist']).'">'.readmore(decode($row['media_artist']),5).'</a>
	</div>
	</div>';
	}
echo '<div class="clr"></div>
    </div>';
} 
//-----------------------------------------------------------
function memberintro($hash){ 
sql2();
	$sql="SELECT * FROM `user` WHERE user_hash='".$hash."'";
	$info=mysql_fetch_assoc(mysql_query($sql));
echo '
<table><tr>
<td class="poster_img"><img src="http://diendan.cailuongso.com/image.php?u='.$info['userid'].'"/></td>
<td style="vertical-align:top">
<a class="poster_intro">Thông tin về thành viên</a>
</td></tr>
</table>
';
}
?>